package gest;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DBConnection {

	static Connection conn;
	static String url = "jdbc:mysql://localhost:3306/";
	static String driver = "com.mysql.jdbc.Driver";
	static String dbName = "gestaoreceitas";
//	static String userName = "Joel";
//	static String password = "1234";
//	static String userName = "assuncao";
//	static String password = "12345";
	static String userName = "root";
	static String password = "poleralco";

	public DBConnection() {
		conn = null;
		try {
			Class.forName(driver).newInstance();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}


	public static Connection get_conn() {
		if (conn == null) {
			try {
				conn = DriverManager.getConnection(url + dbName, userName,
						password);
				System.out.println("Nova connec�‹o");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return conn;
	}

	

}
